import { request as http } from '../service'
import IBaseObj from '#/index'

const base = '/roles'

const getDefaultRolesList = () =>
  http(
    {
      url: `${base}/list/default`,
      method: 'get',
    },
    true
  )

const getMenuByRole = (rid: number) =>
  http(
    {
      url: `${base}/menus/tree/${rid}`,
      method: 'get',
    },
    true
  )

// new

export enum RoleType {
  role, // 角色
  system, // 系统权限
  permission, // 权限(项目权限)
}

const getProjectRoleList = () =>
  http({
    url: `/role/list/project`,
    method: 'get',
  })

const getRoleList = (type: RoleType) =>
  http({
    url: `/role/list`,
    method: 'GET',
    params: {
      type,
    },
  })

export default {
  getDefaultRolesList,
  getMenuByRole,
  getProjectRoleList,
  getRoleList,
}
